package goleetcode

func passThePillow(n int, time int) int {
	cnt := 1
	direction := 1
	for time > 0 {
		cnt += direction
		if cnt == n {
			direction *= -1
		} else if cnt == 1 {
			direction *= -1
		}
		time--
	}
	return cnt
}